/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lily
 * Date: 2024-09-26
 * Time: 11:21
 */
public class evaluate_Tree {
    public boolean evaluateTree(TreeNode root) {
        if (root.val == 1) {
            return true;
        } else if (root.val == 0) {
            return false;
        }
        boolean left = evaluateTree(root.left);
        boolean right = evaluateTree(root.right);

        if (root.val == 2) {
            return left || right;
        } else {
            return left && right;
        }
    }
}
